package com.service.business.order.controller.rep;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.service.business.pay.enums.OrderType;
import com.service.business.product.controller.rep.ProductPayTypeRep;
import com.service.dao.enums.OrderTypeEnum;
import com.service.dao.model.OrderProductHrCombo;
import com.service.dao.model.OrderProductOther;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * <dl>
 * <dt>back-end</dt>
 * <dd>Description:</dd>
 * <dd>Copyright: Copyright (C) 2015</dd>
 * <dd>Company: </dd>
 * <dd>CreateDate: 2019年11月14日</dd>
 * </dl>
 *
 * @author
 */
@Getter
@Setter
@ToString
public class BaseOrderRep {


    private String orderNo;

    private BigDecimal payMoney;

    private String payMoneyCoin;

    private List<ProductPayTypeRep> payTypeList;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date orderTime;

    private Integer orderType;

    private Long overtime;

    private Map<String, BigDecimal> payMoneyMap;

    public static BaseOrderRep buildProductHrCombo(OrderProductHrCombo order, Long overtime) {
        BaseOrderRep result = new BaseOrderRep();
        result.setOrderNo(order.getHrOrderNo());
        result.setPayMoney(order.getOrderMoney());
        result.setOrderTime(order.getCreateTime());
        result.setOrderType(order.getOrderType());
        result.setOvertime(overtime);
        return result;
    }

    public static BaseOrderRep buildProductHrCombo(OrderProductHrCombo order, Long overtime,
                                                   List<ProductPayTypeRep> payTypeList) {
        BaseOrderRep result = new BaseOrderRep();
        result.setOrderNo(order.getHrOrderNo());
        result.setPayMoney(order.getOrderMoney());
        result.setOrderTime(order.getCreateTime());
        result.setOrderType(order.getOrderType());
        result.setOvertime(overtime);
        result.setPayTypeList(payTypeList);
        result.setPayMoneyCoin(payTypeList.get(0).getPayTypeList().get(0).getCoinsName());
        return result;
    }

    public static BaseOrderRep buildProductOther(OrderProductOther orderProductOther, Map<String, BigDecimal> totalPrice, Long overtime) {
        BaseOrderRep result = new BaseOrderRep();
        result.setOrderNo(orderProductOther.getOrderNo());
        result.setOrderTime(orderProductOther.getCreateTime());
        result.setPayMoneyMap(totalPrice);
        result.setOvertime(overtime);
        return result;
    }

    public static BaseOrderRep buildProductOther(OrderProductOther orderProductOther, Long overtime,
                                                 List<ProductPayTypeRep> payTypeList, String payMoneyCoin) {
        BaseOrderRep result = new BaseOrderRep();
        result.setOrderNo(orderProductOther.getOrderNo());
        result.setPayMoney(orderProductOther.getOrderMoney());
        result.setOrderTime(orderProductOther.getCreateTime());
        result.setOrderType(orderProductOther.getOrderType());
        result.setOvertime(overtime);
        result.setPayTypeList(payTypeList);
        result.setPayMoneyCoin(payMoneyCoin);
        return result;
    }


}
